<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.bean.PersonBean"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    
    <title>意见箱</title>
    <link rel="shortcut icon" href="<%=path %>/images/feedback.ico"/>
    <link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" media="screen" charset="UTF-8"/>  
    <link rel="stylesheet" href="<%=path %>/css/themes/start/jquery.ui.all.css"/>
    <link rel="stylesheet" href="<%=path %>/css/demos.css"/>
 	<style type="text/css">
 		#container #nav li{
 			font-family: "新宋体";
 		}
 		#logout{
 			float: right;
 			margin-top: 5px;
 			margin-right: 5px;
 		}
 		body { font-size: 62.5%; }
		label, input { display:block; }
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }	
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
		.validateTips { border: 1px solid transparent; padding: 0.3em; }
 	</style>
 	
	<script src="<%=path %>/js/jquery.min.js" type="text/javascript"></script>
	<script src="<%=path %>/js/animate-bg.js" type="text/javascript"></script> 
	<script src="<%=path %>/js/scripts.js" type="text/javascript"></script> 
	<script type="text/javascript" src="<%=path %>/js/popup.js"></script>  
	<script type="text/javascript" src="<%=path %>/js/popupclass.js"></script>
	
	<script src="<%=path %>/js/external/jquery.bgiframe-2.1.2.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.core.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.widget.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.mouse.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.button.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.draggable.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.position.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.resizable.js"></script>
	<script src="<%=path %>/js/ui/jquery.ui.dialog.js"></script>
	<script src="<%=path %>/js/ui/jquery.effects.core.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
		
			var oldPassword = $( "#oldPassword" ),
			newPassword = $( "#newPassword" ),
			rePassword = $( "#rePassword" ),
			allFields = $( [] ).add( oldPassword ).add( newPassword ).add( rePassword ),
			tips = $( ".validateTips" );

			function updateTips( t ) {
				tips
					.text( t )
					.addClass( "ui-state-highlight" );
				setTimeout(function() {
					tips.removeClass( "ui-state-highlight", 1500 );
				}, 500 );
			}
	
			function checkLength( o, n, min, max ) {
				if ( o.val().length > max || o.val().length < min ) {
					o.addClass( "ui-state-error" );
					updateTips( n + "长度必须在" +
						min + "到" + max + "之间." );
					return false;
				} else {
					return true;
				}
			}
			
			function checkEqual(p, q){
				if(p.val() == q.val()){
					return true;
				}else{
					q.addClass( "ui-state-error" );
					updateTips("新置密码与重复密码不一致");
					return false;
				}
			}
			
			function checkRegexp( o, regexp, n ) {
				if ( !( regexp.test( o.val() ) ) ) {
					o.addClass( "ui-state-error" );
					updateTips( n );
					return false;
				} else {
					return true;
				}
			}
			
			$('#dialog-note').dialog({
				height: 400,
				width: 450,
				modal: true,
				resizable: false
			});
			
			$( "#dialog-form" ).dialog({
				autoOpen: false,
				height: 300,
				width: 350,
				modal: true,
				resizable: false,
				hide: 'slide',
				buttons: {
					"  确  认  ": function() {
						var bValid = true;
						allFields.removeClass( "ui-state-error" );
	
						bValid = bValid && checkLength( oldPassword, "原密码", 6, 16 );
						bValid = bValid && checkLength( newPassword, "新置密码", 6, 16 );
						bValid = bValid && checkLength( rePassword, "重复密码", 6, 16 );
						bValid = bValid && checkEqual( newPassword, rePassword);
	
						if ( bValid ) {
							$('.validateTips').empty();
							$.ajax({
								type: "GET",
								url: "<%=path %>/ajax",
								data: {method: 'changePassword', oldPassword: oldPassword.val(), newPassword: newPassword.val(), rePassword: rePassword.val(), random: Math.random()},
								success : function(data, textStatus){
									if(data == 1){
										alert("新密码设置成功！");
										$("#dialog-form").dialog( "close" );
									}else if(data == -1){
										oldPassword.addClass( "ui-state-error" );
										updateTips("原密码错误");
									}else{
										updateTips("修改密码失败");
									}
									
								},
								error : function(){
									alert("请求失败");
								}
							});
						}
					}
				},
				close: function() {
					allFields.val( "" ).removeClass( "ui-state-error" );
				}
			});
			$( "#changePassword" )
				.click(function() {
					$( "#dialog-form" ).dialog( "open" );
				});
		});
	</script>
  </head>
  
  <body>
  	<div id="container"> 
  		<div id="logout">
  			<a href="<%=path %>/fd.do?method=logout"><img width="50px" height="50px" alt="退出系统" src="<%=path %>/images/close.png"></img></a>
  		</div>
  		<div class="demo">
			<div id="dialog-form" title="修改密码">
				<p class="validateTips"></p>
				<form>
				<fieldset>
					<label for="name">原密码</label>
					<input type="password" name="oldPassword" id="oldPassword" class="text ui-widget-content ui-corner-all" />
					<label for="email">新置密码</label>
					<input type="password" name="newPassword" id="newPassword" value="" class="text ui-widget-content ui-corner-all" />
					<label for="password">确定密码</label>
					<input type="password" name="rePassword" id="rePassword" value="" class="text ui-widget-content ui-corner-all" />
				</fieldset>
				</form>
			</div>
			<div id="dialog-note" title="用户必读">
				<p style="font-size: 16px; font-weight: bold; font-family: '宋体'; line-height: 25px;">为了完善机房的管理，营造开放式管理氛围，增加信息交流平台，增强沟通，并能够及时发现和解决问题，特设立此意见箱。</p>
				<br/>
				<div style="line-height: 25px;">
				<p style="font-size: 15px; font-family: '华文细黑'">注意事项：</p>
				<p style="font-size: 15px; font-family: '华文细黑'">1．发表意见前先搜索是否已有相同内容的问题，以免雷同。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">2．个人提出意见或建议应真实、客观。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">3．不得利用意见箱对他人进行辱骂、恐吓、造谣等人身攻击行为。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">4．请您文明发表意见，禁止一切不健康语言。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">5．意见箱管理员定为机房主任，管理员应在最短时间内对存在的意见和建议给予信息回馈。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">6．对意见箱内私人意见，管理员有对其保密的责任和义务。</p>
				<p style="font-size: 15px; font-family: '华文细黑'">7．初次使用时，请修改个人密码，避免帐号丢失。</p>
				</div>
			</div>
		</div>
	  	<div id="footer">
		  	<center>
			  	<ul id="nav"> 
					<li><a href="#" onclick="ShowIframe('意见处','<%=path %>/jsp/comment.jsp',800,450)"><p>意见处</p></a></li> 
					<%PersonBean bean = (PersonBean)session.getAttribute("person"); 
					  if(bean.getRole().equals("1")){%>
						<li><a href="#" onclick="ShowIframe('反馈箱','<%=path %>/jsp/sessionStaff.jsp',800,450)">反馈箱</a></li> 
					<%} else{%>
						<li><a href="#" onclick="ShowIframe('反馈箱','<%=path %>/jsp/sessionDirecor.jsp',800,450)">反馈箱</a></li> 
					<%} %>
					
					<li><a href="#" onclick="ShowIframe('公共栏','<%=path %>/jsp/publicSession.jsp',800,450)">公共栏</a></li> 
					<li><a href="#" id="changePassword">修改密码</a></li> 
				</ul>
			</center>
		</div>
	</div>
  </body>
</html>
